<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>资讯分类管理-资讯管理-后台管理首页-{:C('siteName')}</title>
        <php>
            $addCss="";
            $addJs="";
            $currentNav ='资讯管理 > 资讯分类管理';
        </php>
        <include file="Common:intoHead" />
    </head>
    <body>
        <div class="wrap">
            <include file="Common:head" />
            <div class="mainBody">
                <include file="Common:left" />
                <div id="Right">
                    <div class="Item hr">
                        <div class="current">资讯分类管理</div>
                    </div>
                    <form action="" method="post" id="quickForm">
                        <b>添加分类：</b>
                        <input type="hidden" name="act" value="add" /> &nbsp;
                        <select name="data[pid]">
                            <option value="0">顶级分类</option>
                            <volist name="list" id="vo">
                                <option value="{$vo.cid}">{$vo.fullname}</option>
                            </volist>
                        </select>  &nbsp;
                        <input placeholder="你要添加的分类名称" id="newName" class="form-control input-sm" type="text" name="data[name]" value="" /> &nbsp;
                        <select name="data[type]" id="newType">
                            <option value="">选择模型</option>
                            <option value="article">新闻模型</option>
                            <option value="product">产品模型</option>
                        </select> &nbsp;
                        <button class="btn quickSubmit">确定添加</button>
                    </form>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab">
                        <thead>
                            <tr>
                                <td>原分类CID</td>
                                <td>原分类结构 <b title="单击分类隐藏/显示该分类下在子类">[i]</b></td>
                                <td align="left">排序</td>
                                <td align="left">操作属性</td>
                                <td>新分类</td>
                                <td>修改后的名称</td>
                                <td>模型</td>
                                <td>是否启用</td>
                                <td>操作</td>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="list" id="tree">
                                <tr pid="{$tree.pid}" cid="{$tree.cid}">
                                    <td align="center">{$tree.cid}<input type="hidden" name="cid" value="{$tree.cid}"/></td>
                                    <td class="tree" style="cursor: pointer;">{$tree.fullname}</td>
                                    <td><input type="text" name="oid" class="form-control input-sm" size="5" value="{$tree.oid}" placeholder="序号"/></td>
                                    <td>
                                        <select name="act" class="act">
                                            <option selected="selected" value="edit">修改该分类</option>
                                            <option value="del">删除该分类</option>
                                            <option value="add">在该分类中添加子类</option>
                                        </select>
                                    </td>
                                    <td>
                                        <select name="pid">
                                            <option value="0">顶级分类</option>
                                            <volist name="list" id="vo1">
                                                <if condition="$vo1['cid'] eq $tree['cid']">
                                                    <option value="{$vo1.cid}" selected="selected" readonly>{$vo1.fullname}</option>
                                                    <else/>
                                                    <option value="{$vo1.cid}">{$vo1.fullname}</option>
                                                </if>
                                            </volist>
                                        </select>
                                    </td>
                                    <td><input type="text" value="" name="name" class="form-control input-sm" placeholder="你要修改分类的新名称"/></td>
                                    <td>
                                        <select name="type">
                                            <option value="article" <if condition="$tree.type eq article"> selected="selected"</if>>新闻模型</option>
                                            <option value="product" <if condition="$tree.type eq product"> selected="selected"</if>>产品模型</option>
                                        </select>
                                    </td>
                                    <td>
                                        <select name="status">
                                            <option value="1" <if condition="$tree.status eq 1"> selected="selected"</if>>启用</option>
                                            <option value="0" <if condition="$tree.status eq 0"> selected="selected"</if>>禁用</option>
                                        </select>
                                    </td>
                                    <td align="center"><button class="btn opCat">确定</button></td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <form action="" method="post" id="opForm">
            <input id="cid" type="hidden" name="data[cid]" />
            <input id="act" type="hidden" name="act" />
            <input id="pid" type="hidden" name="data[pid]" />
            <input id="oid" type="hidden" name="data[oid]" />
            <input id="type" type="hidden" name="data[type]" />
            <input id="name" type="hidden" name="data[name]" />
            <input id="status" type="hidden" name="data[status]" />
        </form>
        <div class="clear"></div>
        <include file="Common:foot" />
        <script type="text/javascript">
            $(function(){
                $(".opCat").click(function(){
                    var obj=$(this).parents("tr");
                    $("#cid").val(obj.find("input[name='cid']").val());
                    $("#act").val(obj.find("select[name='act']").val());
                    $("#pid").val(obj.find("select[name='pid']").val());
                    $("#oid").val(obj.find("input[name='oid']").val());
                    $("#name").val(obj.find("input[name='name']").val());
                    $("#type").val(obj.find("select[name='type']").val());
                    $("#status").val(obj.find("select[name='status']").val());
                    if($("#act").val()=="del"){
                        popup.confirm('你真的打算删除该分类吗?','温馨提示',function(action){
                            if(action == 'ok'){
                                ajaxSubmit("","#opForm");
                            }
                        });
                        return false;
                    }
                    ajaxSubmit("","#opForm");
                });
                $(".quickSubmit").click(function(){
                    if($("#newName").val()==''){
                        popup.alert("分类名称不能为空滴！");
                        return false;
                    }
                    if($("#newType").val()==''){
                        popup.alert("请选择模型！");
                        return false;
                    }
                    ajaxSubmit("","#quickForm");
                    return false;
                });

                var chn=function(cid,op){
                    if(op=="show"){
                        $("tr[pid='"+cid+"']").each(function(){
                            $(this).removeAttr("status").show();
                            chn($(this).attr("cid"),"show");
                        });
                    }else{
                        $("tr[pid='"+cid+"']").each(function(){
                            $(this).attr("status",1).hide();
                            chn($(this).attr("cid"),"hide");
                        });
                    }
                }
                $(".tree").click(function(){
                    if($(this).attr("status")!=1){
                        chn($(this).parent().attr("cid"),"hide");
                        $(this).attr("status",1);
                    }else{
                        chn($(this).parent().attr("cid"),"show");
                        $(this).removeAttr("status");
                    }
                });
            });
        </script>
    </body>
</html>
